package com.webage.ejbs;

import java.util.ArrayList;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import nl.saxion.act.dao.CustomerDao;
import nl.saxion.act.entity.Customer;
import nl.saxion.act.entity.Order;
import nl.saxion.act.entity.Product;

@Stateless(name = "CustomerBean", mappedName = "ejb/CustomerBeanJNDI")  
public class CustomerBean implements ICustomerBean{
	private CustomerDao customerdao /*= new CustomerDao()*/;
	private long order_id = -1;
	
	@Override
	public ArrayList<Order> getOverview(String customername) {
		//return customerdao.getOrdersFromCustomer(id);
		
		//hardcoded
		ArrayList<Order> orderlist = new ArrayList<Order>();
		Product prod1 = new Product(10, "Kaas", "Zuivel");
	    Product prod2 = new Product(10, "Melk", "Zuivel");
	    Product prod3 = new Product(10, "Ei", "Zuivel");
	    
	    Order ord1 = new Order();
	    ord1.setCustomer(new Customer("Fleur"));
	    ord1.addProduct( prod1 );
	    ord1.addProduct( prod2 );
	    ord1.addProduct( prod3 );
	    
		orderlist.add(ord1);
		
		return orderlist;
	}

	@Override
	public void addOrder(int customerid) {
		// order_id = customerdao.addOrder(customerid);
	}

	@Override
	public void orderProducts(int prod_nr, int number) {
		if(order_id > 0 ){
			//ProductDao productdao = new ProductDao();
			//Product product = productdao.getProductById(prod_nr);
			//customerdao.orderProducts(order_id, product,number);
		}
	}
}
